﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using NHibernate.Mappings;
using System.Security.Principal;

namespace Apollo
{
    [Serializable]
    [NHibernateEntity(Table = "Users")]
    public class User : MarshalByRefObject, IUser
    {
        public User() { }

        public virtual bool IsAuthenticated { get; set; }

        [PrimaryKey]
        public virtual int Id { get; set; }

        [Property]
        public virtual string AuthenticationType { get; set; }

        [Property]
        public virtual string Name { get; set; }

        [Property]
        public virtual string Password { get; set; }

        [BelongsTo(Column = "ID_Language")]
        public virtual Language Language { get; set; }

        [BelongsTo(Column = "ID_Role")]
        public virtual Role Role { get; set; }

        [BelongsTo(Column = "ID_Position")]
        public virtual Position Position { get; set; }

        //[BelongsTo(Column = "ID_Employee")]
        //public virtual Employee Employee { get; set; }

        [BelongsTo(Column = "ID_Impersonate_User")]
        public virtual User Impersonate { get; set; }


        [Property]
        public virtual DateTime LastLoginDate { get; set; }

        [Property]
        public virtual bool IsActive { get; set; }

        [Property]
        public virtual DateTime InsertDate { get; set; }

        [Property]
        public virtual string InsertBy { get; set; }

        [Property]
        public virtual DateTime? ModifiedDate { get; set; }

        [Property]
        public virtual string ModifiedBy { get; set; }

    }

    public interface IUser : IIdentity, ITrackable, IPositionable {
        int Id { get; set; }

        new bool IsAuthenticated { get; set; }

        Language Language { get; set; }

        Role Role { get; set; }

        User Impersonate { get; set; }

        DateTime LastLoginDate { get; set; }

        bool IsActive { get; set; }
    }
}
